
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QWidget
from PySide2.QtGui import QPaintEvent,QPainter,QBrush,QPen,QColor

from UI.changecolordialog import ChangeColorDialog
from UI.ui_otherusewidget import Ui_OtherUseWidget


class OtherUseWidget(QWidget):
    def __init__(self, parent: QWidget= None) -> None:
        super(OtherUseWidget,self).__init__(parent)

        self.ui=Ui_OtherUseWidget()
        self.ui.setupUi(self)

        self.setAttribute(Qt.WA_TranslucentBackground)

    def SetCPUUseValue(self,inValue:int):
        self.ui.label_CPUValue.setText(str(inValue)+"%")

    def SetMemUseValue(self,inValue:int):
        self.ui.label_MemoryValue.setText(str(inValue)+"%")

    def paintEvent(self, event: QPaintEvent) -> None:
        super().paintEvent(event)
        painter=QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setBrush(QBrush(ChangeColorDialog.Color))
        painter.setPen(QPen(Qt.transparent))
        painter.drawRoundedRect(self.rect(),6,6)

